package com.doujiang.util;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import jakarta.servlet.http.HttpServletRequest;

public class TableSupport {
    public static PageDomain buildPageRequest() {
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        PageDomain pageDomain = new PageDomain();
        String pageNumStr = request.getParameter("pageNum");
        String pageSizeStr = request.getParameter("pageSize");
        pageDomain.setPageNum(pageNumStr == null ? 1 : Integer.parseInt(pageNumStr));
        pageDomain.setPageSize(pageSizeStr == null ? 10 : Integer.parseInt(pageSizeStr));
        return pageDomain;
    }
}